function [circumcenter] = find_circumcenter(nodes)
    % 计算三角形的外心
    % 输入: nodes- 三角形三个顶点的坐标，为3x2向量
    % 输出: circumcenter - 外心坐标，1x2向量
    
    %找到两条直线，至少存在一条不垂直坐标轴，一条不垂直x轴
    need_value = zeros(2,3);%两条边,存一个中点，一个斜率
    index = 1;
    for i = 1 : 3
        switch i
            case 1
                node1 = nodes(1,:);
                node2 = nodes(2,:);
            case 2
                node1 = nodes(1,:);
                node2 = nodes(3,:);
            case 3
                node1 = nodes(2,:);
                node2 = nodes(3,:);
        end
        if node1(1)~=node2(1)
            k = (node2(2) - node1(2)) / (node2(1) - node1(1));
            if abs(k)>1e-10
                x_mid = 0.5*(node1(1) + node2(1));
                y_mid = 0.5*(node1(2) + node2(2));
                need_value(index,1:2) = [x_mid,y_mid];
                need_value(index,3) = -1/k;
                index = index + 1;
                if index == 3
                    break;
                end
            end
        else
            x_mid = 0.5*(node1(1) + node2(1));
            y_mid = 0.5*(node1(2) + node2(2));
            need_value(index,1:2) = [x_mid,y_mid];
            need_value(index,3) = 0;
            index = index + 1;
            if index == 3
                break;
            end
        end
    end
    [va, po] = min(abs(need_value));
    if va == 0
        for i = 1 : 2
            if i~=po
                k = need_value(i,3);
                x_mid = need_value(i,1);
                y_mid = need_value(i,2);
                b1 = y_mid - k*x_mid;
            end
        end
        b2 = need_value(po,2);
        x = (b2 - b1)/k;
        y = k*x + b1;
    else
        k1 = need_value(1,3);
        k2 = need_value(2,3);
        b1 = need_value(1,2) - k1*need_value(1,1);
        b2 = need_value(2,2) - k2*need_value(2,1);
        x = (b2 - b1)/(k1 - k2);
        y = k1*x + b1; 
    end
    circumcenter = [x, y];
end